package JXY02.Day02;


import java.util.Objects;

/**
 * 定义私有属性:
 * String name;
 * int age;
 * String gender;
 * int salary;
 * 定义全参数(该构造方法的参数用于设置所有属性)构造方法与默认构造方法
 * 重写toString方法，返回字符串格式如:"张三,25,男,5000"
 * 重写equals方法，要求名字相同就认为内容一致。
 *
 */
public class Person {
    private String name;
    private int age;
    private String gender;
    private int salary;

    static Person person1 = new Person();
    static Person person2 = new Person("张三",22,"男",8888);
    static Person person3 = new Person("李四",44,"男",4444);

    public Person(){
        name = "张三";
        age = 25;
        gender = "男";
        salary = 5000;
    }
    public Person(String name,int age,String gender,int salary){
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.salary = salary;
    }
    public String toString(){
        return this.name +','+ this.age +',' + this.gender + ',' + this.salary;
    }
    public Boolean equals(Person person){

        return Objects.equals(this.name, person.name);
    }

    public static void main(String[] args) {
        System.out.println(person1.toString());
        System.out.println(person2.toString());
        System.out.println(person3.toString());
        System.out.println(person1.equals(person2));
        System.out.println(person1.equals(person3));
    }
}
